//addpntrs.cpp -- pointer addition
#include <iostream>
int main()
{
	using namespace std;
	double wagges[3] = { 10000.0,20000.0,30000.0 };
	short stacks[3] = { 3,2,1 };

	//Here are two ways to get the address of an array
	double* pw = wagges;		//name of an array = address
	short* ps = &stacks[0];		//or use address operator
	//with array element
	cout << "pw = " << pw << ",*pw = " << *pw << endl;
	pw = pw + 1;
	cout << "add 1 to the pw pointer:\n";
	cout << "pw = " << pw << "，*pw = " << *pw << "\n\n";
	cout << "ps = " << ps << "，*ps = " << *ps << endl;
	ps = ps + 1;
	cout << "add 1 to the ps pointer:\n";
	cout << "ps = " << ps << "，*ps = " << *ps << "\n\n";

	cout << "access two elements with array notation\n";
	cout << "stacks[0] = " << stacks[0]
		<< ", stacks[1] = " << stacks[1] << endl;
	cout << "access two elements with pointer notation\n";
	cout << "*stacks = " << *stacks
		<< ", *(stacks+1) = " << *(stacks + 1) << endl;


	cout << sizeof(wagges) << "= sizeof wages array\n";
	cout << sizeof(pw) << " = sizeof pw pointer\n";


	int tacos[10] = { 5,2,8,4,1,2,2,4,6,8 };
	int* pt = tacos;
	pt = pt + 1;
	int* pe = &tacos[9];
	pe = pe - 1;
	int diff = pe - pt;
	cout << "diff = "<< diff << endl;

	return 0;
}